package com.framework.model.common;

import com.framework.common.annotation.QueryParam;
import com.framework.common.model.validation.ValidationGroup;
import com.framework.common.util.other.NumeralUtil;
import com.framework.model.base.BaseModel;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;

/**
 * @author 龘鵺
 * @version 1.0
 * @className com.framework.model.common.Protocol
 * @title 协议类
 * @datetime 2024-06-19 14:54:56
 */
public class Protocol extends BaseModel implements Serializable {
    /**
     * 启用状态=1启用,2禁用 ENABLE_STATUS
     */
    @NotNull(message = "请选择启用状态", groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class, ValidationGroup.formQuery.class})
    @Min(message = "启用状态错误", value = NumeralUtil.POSITIVE_ONE, groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class, ValidationGroup.formQuery.class})
    @Max(message = "启用状态错误", value = Integer.MAX_VALUE, groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class, ValidationGroup.formQuery.class})
    @QueryParam(name = "enableStatus", code = "p.ENABLE_STATUS")
    private Integer enableStatus;

    /**
     * 协议类型 PROTOCOL_TYPE
     */
    @NotNull(message = "请选择协议类型", groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class, ValidationGroup.formQuery.class})
    @Min(message = "协议类型错误", value = NumeralUtil.POSITIVE_ONE, groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class, ValidationGroup.formQuery.class})
    @Max(message = "协议类型错误", value = Integer.MAX_VALUE, groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class, ValidationGroup.formQuery.class})
    @QueryParam(name = "protocolType", code = "p.PROTOCOL_TYPE")
    private Integer protocolType;

    /**
     * 协议标题 PROTOCOL_TITLE
     */
    @NotBlank(message = "请输入协议标题", groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class, ValidationGroup.formQuery.class})
    @Size(message = "协议标题最多256字符", max = 256, groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class, ValidationGroup.formQuery.class})
    @QueryParam(name = "protocolTitle", code = "p.PROTOCOL_TITLE")
    private String protocolTitle;

    /**
     * 协议分类 PROTOCOL_CLASSIFICATION
     */
    @NotNull(message = "请选择协议分类", groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class, ValidationGroup.formQuery.class})
    @Min(message = "协议分类错误", value = NumeralUtil.POSITIVE_ONE, groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class, ValidationGroup.formQuery.class})
    @Max(message = "协议分类错误", value = Integer.MAX_VALUE, groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class, ValidationGroup.formQuery.class})
    @QueryParam(name = "protocolClassification", code = "p.PROTOCOL_CLASSIFICATION")
    private Integer protocolClassification;

    /**
     * 初始编号 INIT_ID
     */
//    @NotNull(message = "请选择初始编号", groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class, ValidationGroup.formQuery.class})
//    @Min(message = "初始编号不存在", value = NumeralUtil.POSITIVE_ONE, groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class, ValidationGroup.formQuery.class})
//    @Max(message = "初始编号不存在", value = Long.MAX_VALUE, groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class, ValidationGroup.formQuery.class})
    @QueryParam(name = "initId", code = "p.INIT_ID")
    private Long initId;

    /**
     * 协议内容 PROTOCOL_CONTENT
     */
    @NotBlank(message = "请输入协议内容", groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class, ValidationGroup.formQuery.class})
    @Size(message = "协议内容最多65535字符", max = 65535, groups = {ValidationGroup.formEdit.class, ValidationGroup.formAdd.class, ValidationGroup.formQuery.class})
    @QueryParam(name = "protocolContent", code = "p.PROTOCOL_CONTENT")
    private String protocolContent;

    /**
     * t_protocol
     */
    private static final long serialVersionUID = 1L;

    public Integer getEnableStatus() {
        return enableStatus;
    }

    public void setEnableStatus(Integer enableStatus) {
        this.enableStatus = enableStatus;
    }

    public Integer getProtocolType() {
        return protocolType;
    }

    public void setProtocolType(Integer protocolType) {
        this.protocolType = protocolType;
    }

    public String getProtocolTitle() {
        return protocolTitle;
    }

    public void setProtocolTitle(String protocolTitle) {
        this.protocolTitle = protocolTitle == null ? null : protocolTitle.trim();
    }

    public Integer getProtocolClassification() {
        return protocolClassification;
    }

    public void setProtocolClassification(Integer protocolClassification) {
        this.protocolClassification = protocolClassification;
    }

    public Long getInitId() {
        return initId;
    }

    public void setInitId(Long initId) {
        this.initId = initId;
    }

    public String getProtocolContent() {
        return protocolContent;
    }

    public void setProtocolContent(String protocolContent) {
        this.protocolContent = protocolContent == null ? null : protocolContent.trim();
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(getClass().getSimpleName());
        sb.append(" [");
        sb.append("Hash = ").append(hashCode());
        sb.append(", enableStatus=").append(enableStatus);
        sb.append(", protocolType=").append(protocolType);
        sb.append(", protocolTitle=").append(protocolTitle);
        sb.append(", protocolClassification=").append(protocolClassification);
        sb.append(", initId=").append(initId);
        sb.append(", protocolContent=").append(protocolContent);
        sb.append(", serialVersionUID=").append(serialVersionUID);
        sb.append("]");
        return sb.toString();
    }

    @Override
    public boolean equals(Object that) {
        if (this == that) {
            return true;
        }
        if (that == null) {
            return false;
        }
        if (getClass() != that.getClass()) {
            return false;
        }
        Protocol other = (Protocol) that;
        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
            && (this.getCreateId() == null ? other.getCreateId() == null : this.getCreateId().equals(other.getCreateId()))
            && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
            && (this.getOperaterId() == null ? other.getOperaterId() == null : this.getOperaterId().equals(other.getOperaterId()))
            && (this.getOperaterTime() == null ? other.getOperaterTime() == null : this.getOperaterTime().equals(other.getOperaterTime()))
            && (this.getOperaterStatus() == null ? other.getOperaterStatus() == null : this.getOperaterStatus().equals(other.getOperaterStatus()))
            && (this.getEnableStatus() == null ? other.getEnableStatus() == null : this.getEnableStatus().equals(other.getEnableStatus()))
            && (this.getProtocolType() == null ? other.getProtocolType() == null : this.getProtocolType().equals(other.getProtocolType()))
            && (this.getProtocolTitle() == null ? other.getProtocolTitle() == null : this.getProtocolTitle().equals(other.getProtocolTitle()))
            && (this.getProtocolClassification() == null ? other.getProtocolClassification() == null : this.getProtocolClassification().equals(other.getProtocolClassification()))
            && (this.getInitId() == null ? other.getInitId() == null : this.getInitId().equals(other.getInitId()))
            && (this.getProtocolContent() == null ? other.getProtocolContent() == null : this.getProtocolContent().equals(other.getProtocolContent()));
    }

    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
        result = prime * result + ((getCreateId() == null) ? 0 : getCreateId().hashCode());
        result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
        result = prime * result + ((getOperaterId() == null) ? 0 : getOperaterId().hashCode());
        result = prime * result + ((getOperaterTime() == null) ? 0 : getOperaterTime().hashCode());
        result = prime * result + ((getOperaterStatus() == null) ? 0 : getOperaterStatus().hashCode());
        result = prime * result + ((getEnableStatus() == null) ? 0 : getEnableStatus().hashCode());
        result = prime * result + ((getProtocolType() == null) ? 0 : getProtocolType().hashCode());
        result = prime * result + ((getProtocolTitle() == null) ? 0 : getProtocolTitle().hashCode());
        result = prime * result + ((getProtocolClassification() == null) ? 0 : getProtocolClassification().hashCode());
        result = prime * result + ((getInitId() == null) ? 0 : getInitId().hashCode());
        result = prime * result + ((getProtocolContent() == null) ? 0 : getProtocolContent().hashCode());
        return result;
    }
}